import { QuestionBase, SelectQuestion, TextQuestion, TitleQuestion, UploadQuestion } from '@/components/public-template';
import { TextTable } from '@/components/public-template';
import { TableBase } from '@/components/public-template';
import { Api as ApiResource } from '@/config/api/resourceFileInfo';

class HomeService {
  getTitleQuestions() {
    const questions: QuestionBase<any>[] = [
      new TitleQuestion({
        label: '档案目录',
        state: { noShrink: true }
      })
    ];
    return questions;
  }
  getListTables() {
    const tables: TableBase<any>[] = [
      new TextTable({
        key: 'num',
        value: '序号',
        type: 'index'
      }),
      new TextTable({
        key: 'filesBoxCode',
        value: '档案编码'
      }),
      new TextTable({
        key: 'name',
        value: '文件名称'
      })
    ];
    return tables;
  }
  getTargetFileQuestions(toDepartment) {
    const questions: QuestionBase<any>[] = [
      new TitleQuestion({
        label: '目标档案盒',
        state: { noShrink: true }
      }),
      new SelectQuestion({
        key: 'filesBoxId',
        label: '档案盒编码',
        prompt: '请选择',
        value: null,
        state: {
          mode: 'combobox',
          showSearch: true,
          url: '/dms/archives/box/findCanUseBox',
          protType: 'post',
          nameKey: 'code',
          nameValue: 'id',
          optionFilterProp: 'label',
          params: {
            typeId: '',
            toDepartment: '',
            filesBoxId: ''
          }
        }
      })
    ];
    return questions;
  }
  getTargetFileTables() {
    const tables: TableBase<any>[] = [
      new TextTable({
        key: 'num',
        value: '序号',
        type: 'index'
      }),
      new TextTable({
        key: 'filesBoxCode',
        value: '档案编码'
      }),
      new TextTable({
        key: 'name',
        value: '文件名称'
      })
    ];
    return tables;
  }
  getDetailQuestions(id) {
    const questions: QuestionBase<any>[] = [
      new TitleQuestion({
        label: '档案盒',
        state: { noShrink: true }
      }),
      new TextQuestion({
        key: 'boxCode',
        label: '档案盒编码',
        value: null
      }),
      new TextQuestion({
        key: 'boxName',
        label: '档案盒名称',
        value: null
      }),
      new TextQuestion({
        key: 'boxDesc',
        label: '描述',
        value: null
      }),
      new TitleQuestion({
        label: '档案详情',
        state: { noShrink: true }
      }),
      new TextQuestion({
        key: 'source',
        label: '文件来源',
        value: null,
        type: 'dictionary',
        state: {
          filterName: 'ARCHIVES_SOURCE'
        }
      }),
      new TextQuestion({
        key: 'code',
        label: '文件编码',
        value: null
      }),
      new TextQuestion({
        key: 'fileCode',
        label: '文件号',
        value: null
      }),
      new TextQuestion({
        key: 'type',
        label: '载体形式',
        value: null,
        type: 'dictionary',
        state: {
          filterName: 'CARRIER_TYPE'
        }
      }),
      new TextQuestion({
        key: 'filePages',
        label: '文件页数',
        value: null
      }),
      new TextQuestion({
        key: 'filesTypeName',
        label: '档案类型',
        value: null
      }),
      new TextQuestion({
        key: 'secretLevel',
        label: '保密等级',
        value: null,
        type: 'dictionary',
        state: {
          filterName: 'SECRET_LEVEL'
        }
      }),
      new TextQuestion({
        key: 'toDepartmentName',
        label: '归档部门',
        value: null
      }),
      new TextQuestion({
        key: 'eachOther',
        label: '互见号',
        value: null
      }),
      new TextQuestion({
        key: 'chargeUserIdName',
        label: '责任者',
        value: null
      }),
      new TextQuestion({
        key: 'fromDate',
        label: '形成日期',
        value: null
      }),
      new TextQuestion({
        key: 'toDate',
        label: '归档日期',
        value: null
      }),
      new TextQuestion({
        key: 'retentionPeriodDate',
        label: '保管期限',
        value: null,
        type: 'dictionary',
        state: {
          filterName: 'DMS_ARCHIVES_FILE_LIST_RETENTION_PERIOD_DATE'
        }
      }),
      new TextQuestion({
        key: 'remark',
        label: '说明',
        state: { grid: 8 },
        value: null
      }),
      new UploadQuestion({
        key: 'attachment',
        label: '附件',
        value: null,
        type: 'static',
        state: {
          listType: 'text',
          viewUrl: ApiResource.advancedQueryPreview,
          params: { needRecord: false, previewId: id },
          previewFile: true,
          grid: 24,
          fileIdPreview: {
            needRecord: false
          },
          fieldNames: {
            fileId: 'fileId',
            name: 'name',
            size: 'size',
            suffix: 'suffix'
          }
        }
      })
    ];
    return questions;
  }
}

export default new HomeService();
